﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Gammar.Digger.BLL;
using Gammar.Digger.Entity;
public partial class website_manage : System.Web.UI.Page
{
    private string _website_id = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {
        _website_id = Request.QueryString["site_id"];

        if (!IsPostBack)
        {
            if (!string.IsNullOrEmpty(_website_id))
            {
                BindControls();
            }
        }
    }

    private void BindControls()
    {
        web_siteEntity site = WebSiteManagement.GetSiteById(_website_id);

        if (site != null)
        {
            txtSiteid.Text = site.site_id.ToString();
            txtSiteName.Text = site.name;
            txtSiteDesc.Text = site.description;
            WebSiteCategoryDDL1.BindKey = site.category_id.ToString();
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        DropDownList ddl = WebSiteCategoryDDL1.FindControl("DropDownList1") as DropDownList;
        if (string.IsNullOrEmpty(_website_id))
        {
            Label1.Text = WebSiteManagement.CreateNewWebSite(txtSiteName.Text, txtSiteDesc.Text, ddl.SelectedValue);
        }
        else
        {
            Label1.Text = WebSiteManagement.UpdateWebSite(txtSiteName.Text, txtSiteDesc.Text, ddl.SelectedValue, txtSiteid.Text);
        }

    }
}
